using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace PUCIT.eFCS.DataAccess.Models.Mapping
{
    public class sectionUserMap : EntityTypeConfiguration<sectionUser>
    {
        public sectionUserMap()
        {
            // Primary Key
            this.HasKey(t => t.sectionUserId);

            // Properties
            this.Property(t => t.category)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("sectionUser");
            this.Property(t => t.sectionUserId).HasColumnName("sectionUserId");
            this.Property(t => t.sectionId).HasColumnName("sectionId");
            this.Property(t => t.userId).HasColumnName("userId");
            this.Property(t => t.category).HasColumnName("category");

            // Relationships
            this.HasRequired(t => t.section)
                .WithMany(t => t.sectionUsers)
                .HasForeignKey(d => d.sectionId);
            this.HasRequired(t => t.user)
                .WithMany(t => t.sectionUsers)
                .HasForeignKey(d => d.userId);

        }
    }
}
